Skip to content

[FIX] html_editor: link popover not hidden on clicking other element #4762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

dabo-odoo
Copy link

@dabo-odoo dabo-odoo commented May 21, 2025

Before this commit clicking on certain elements with a link popover
open would not cause the link popover to close.

Steps to reproduce:

  • go to the website homepage
  • open the editor
  • click on any top menu links like Home or Contact Us
  • click on the user dropdwon in the topbar (usually Administrator)
  • the popover from the first click is still open

After the change clicking anywere that's not the popover's current
link will cause the popover to close.

@robodoo
Copy link

robodoo commented May 21, 2025

This PR targets the un-managed branch odoo-dev/odoo:master-mysterious-egg-next, it needs to be retargeted before it can be merged.

@ged-odoo ged-odoo force-pushed the master-mysterious-egg-next branch from 6e36b56 to 48edd7d Compare May 22, 2025 07:31
@dabo-odoo dabo-odoo force-pushed the master-mysterious-egg-dabo-link-popover-not-disappearing-on-click-other-element branch 3 times, most recently from 9930a96 to e6979cf Compare May 23, 2025 06:30
Copy link

@Jinjiu96 Jinjiu96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My feedback 🙏

Comment on lines 276 to 278
// Some elements can be clicked on without the selection being changed
// In those cases the overlay closing and opening must be done manually
this.addDomListener(this.editable, "click", (ev) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I think this is not the right place to fix the issue. The root cause is that when clicking some elements, the selection is not changed. Most likely, they prevented default on these elements. This influences all the selection change handlers.

For example, with the current fix, when you select text from Home button and the tool bar will popup, then you click the Administrator drop down, the toolbar stays open.

IMO, we should check why the selection change is prevented and make the fix there 🤔

Also we already have a click event listener, so if you still need to do the changes at click, you can probably move the code there :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I thought the selection not changing when clicking on certain elements was intended behaviour, I will fix that and it should also fix the popup not closing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jinjiu96 I found out that the selectionchanged event does not fire if the element has contenteditable="false", since if a not editable element is clicked the selection does not move.
I tried solving this by manually moving the cursor (to trigger selectionchanged) if the clicked on element is not editable, let me know if it's acceptable.
I decided to move the cursor to the closest container, but that is completely arbitrary and if you have any better idea let me know.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... moving the cursor sounds kinda hacky, maybe the overlay in the editable should be closed when clicking on the contenteditable="false" elements? Then the toolbar and link popover will be both properly closed?

Also you need to retarget to master IIRC

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I will close this one then

@ged-odoo ged-odoo force-pushed the master-mysterious-egg-next branch from 2e9b9d5 to 8c5e439 Compare May 26, 2025 09:15
@ged-odoo ged-odoo force-pushed the master-mysterious-egg-next branch from 8c5e439 to 2e0c6b5 Compare May 26, 2025 09:23
@dabo-odoo dabo-odoo force-pushed the master-mysterious-egg-dabo-link-popover-not-disappearing-on-click-other-element branch from e6979cf to 07dad12 Compare May 26, 2025 09:46
This commit contains multiple changes squashed together, coming from
various pull requests on master-mysterious-egg. These changes includes:

- No image in colorpicker and working gradient editor for preset background
- Clean carousel related tests, remove repeated ones and merge/rename files
- Fix logo adding/removing option
- Use only "color" tabs in countdown color picker options
- Add support for compact hex colors (e.g. #fff)
- Fix color styling
- Fix setExtraStep
- Auto-optimize image upon replace media
- Adapt extra product image to also rely on openMediaDialog
- Use correct mimetype fields from dataset
- Adapt tests
- Refresh Dynamic Snippet Carousel when scrolling mode is changed

Co-authored-by: Alessandro Lupo <[email protected]>
Co-authored-by: Benoit Socias <[email protected]>
Co-authored-by: divy-odoo <[email protected]>
Co-authored-by: emge-odoo <[email protected]>
Co-authored-by: FrancoisGe <[email protected]>
Co-authored-by: Jinjiu Liu <[email protected]>
Co-authored-by: Keval Bhatt <[email protected]>
Co-authored-by: Serhii Rubanskyi - seru <[email protected]>
@ged-odoo ged-odoo force-pushed the master-mysterious-egg-next branch from 2e0c6b5 to 8478118 Compare May 26, 2025 09:50
Before this commit clicking on certain elements with a link popover
open would not cause the link popover to close.

Steps to reproduce:
- go to the website homepage
- open the editor
- click on any top menu links like Home or Contact Us
- click on the user dropdwon in the topbar (usually Administrator)
- the popover from the first click is still open

After the change clicking anywere that's not the popover's current
link will cause the popover to close.
@dabo-odoo dabo-odoo force-pushed the master-mysterious-egg-dabo-link-popover-not-disappearing-on-click-other-element branch from 07dad12 to ce2b531 Compare May 26, 2025 10:58
@ged-odoo ged-odoo force-pushed the master-mysterious-egg-next branch 4 times, most recently from 7b6e21e to 921bf70 Compare May 27, 2025 06:36
@Jinjiu96
Copy link

retargeted to master at odoo#212041

@Jinjiu96 Jinjiu96 closed this May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants